/**
 * 饿汉模式
 * 通过jvm的类加载机制来实现单例
 */
public class SingleTonHungry {
    public static void main(String[] args) {
        SingleTon singleTon = SingleTon.getSingleTon();
        SingleTon singleTon1 = SingleTon.getSingleTon();
        System.out.println(singleTon == singleTon1);
    }
}
class SingleTon{
    private static SingleTon singleTon = new SingleTon();

    private SingleTon(){}

    public static SingleTon getSingleTon(){
        return singleTon;
    }
}
